//销售员第一层



var express = require('express');
var router = express.Router();
const { getSalesmans, addSalesmans, deleteSalesmans, updateSalesmans} = require('../service/salesmansServce');
const { salesmansLogin,getSellersOrderById  } = require('../service/salesmansService')

//销售员登录
router.post('/login', async function (req, res, next) {
    const data = await salesmansLogin(req.body)
    res.send(data)
})

//获取销售员
router.get('/', async (req, res, next) => {
    res.send(await getSalesmans(req.body));
})

//新增销售员
router.post('/addSalesmans', async (req, res, next) => {
    res.send(await addSalesmans(req.body));
})
// 删除销售员
router.post('/deleteSalesmans', async (req, res) => {
    res.send(await deleteSalesmans(req.body))
})
// 根据_id获取我的全部订单
router.get('/getSellersOrderById', async function (req, res, next) {
    const data = await getSellersOrderById(req.query);
    console.log(req.query);
    console.log(data);
    res.send(data)
});

// //修改销售员
router.post('/updateSalesmans', async (req, res) => {
    res.send(await updateSalesmans(req.body))
})

module.exports = router;